#include<iostream>
using namespace std;
const int N = 1e3 + 10;
int a[N];
int main()
{
    int n; cin >> n;
    for (int i = 1; i <= n; i++)
    {  
        int k; cin >> k;
        for (int j = 1; j <= k; j++)
        {
            int x; cin >> x;
            a[x]++;
        }
    }
    int m = 0, p = 0;
    for (int i = 1; i <= 1000; i++)
    {
        if (a[i] >= m) m = a[i], p = i;
    }
    cout << p << " " <<  a[p] << endl;
    return 0;
}